package cn.mulanbay.log.handler;

import cn.mulanbay.api.system.service.RemoteUserService;
import cn.mulanbay.business.cache.YcCache;
import cn.mulanbay.business.handler.BaseHandler;
import cn.mulanbay.log.persistent.service.ErrorCodeDefineService;
import cn.mulanbay.persistent.entity.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

/**
 * @author fenghong
 * @date 2022年01月16日 10:13
 */
@Component
public class LogHandler extends BaseHandler {

    private static final Logger logger = LoggerFactory.getLogger(LogHandler.class);

    @Autowired
    ErrorCodeDefineService errorCodeDefineService;

    @Lazy
    @Autowired
    RemoteUserService remoteUserService;

    public LogHandler() {
        super("日志处理");
    }

    public void updateErrorCodeCount(Integer code,int cc){
        errorCodeDefineService.updateCount(code,cc);
    }

    @YcCache(key = "'user:'+ #userId")
    public User getUser(Long userId){
        return remoteUserService.getUser(userId).getData();
    }

}
